package org.andy.shop.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.jdbc.core.RowMapper;

import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import java.io.Serializable;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;

/**
 * @Author: Chen
 * @Date: 2016/4/16 14:30
 * @Email: wirechen@gmail.com
 * @Description:
 */
public class UserInfo implements RowMapper<UserInfo>, Serializable {

    /**
     *
     */
    private static final long serialVersionUID = -8823504831198719837L;

    private Integer id;
    private String uname;
    private Integer unumber;
    private Date uRegisterTime;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getUname() {
        return uname;
    }

    public void setUname(String uname) {
        this.uname = uname == null ? null : uname.trim();
    }

    public Integer getUnumber() {
        return unumber;
    }

    public void setUnumber(Integer unumber) {
        this.unumber = unumber;
    }

//    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @Temporal(TemporalType.TIME)
    public Date getuRegisterTime() {
        return uRegisterTime;
    }

    public void setuRegisterTime(Date uRegisterTime) {
        this.uRegisterTime = uRegisterTime;
    }

    public UserInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
        UserInfo userInfo = new UserInfo();
        userInfo.setId(rs.getInt("id"));
        userInfo.setUname(rs.getString("uname"));
        userInfo.setUnumber(rs.getInt("unumber"));
        userInfo.setuRegisterTime(rs.getDate("uregister_time"));
        return userInfo;
    }

}